<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <div id="app">


  </div>
  <!-- 引入React依赖 -->
  <script src="../React/react.development.js"></script>
  <script src="../React/react-dom.development.js"></script>
  <script src="../React/babel.min.js"></script>

  <!-- 编写React代码 -->
  <script type="text/babel">
    class App extends React.Component {
      constructor() {
        super()
        //定义变量
        this.state = {
          firstName: "kobe",
          lastName: "bryant",
          isLogin: true,
        }
      }
      render() {
        const { firstName, lastName,isLogin } = this.state

        return (
          <div>
            {/* 运算符表达式*/}
            <h2>{firstName + " " + lastName}</h2>
            <h2>{20 * 50}</h2>

            {/* 三元表达式*/}
            <h2>{isLogin ? "欢迎回来~" : "请先登录"}</h2>

            {/* 函数调用 */}
            <h2>{this.getFullName()}</h2>

          </div>
        )
      }

      getFullName() {
        return this.state.firstName + " " + this.state.lastName
      }

    }
  </script>

  <script type="text/babel">
    ReactDOM.render(<App />, document.getElementById("app"))
  </script>

</body>

</html>